<?php defined('RUN_KATANA') or die('Restricted access');
class AccessLevel extends Object
{
	public $Title;
	public $Active;
	
	public function AccessLevel() 
	{ 
		self::setDataChanged(false);
	}
	
	public function getTitle() { return $this->Title;  }
	public function getActive() { return intval($this->Active); }
	/* Groups */
	
	public function setTitle($val) { $this->Title=$val;  }
	public function setActive($val) { $this->Active=intval($val); }
	
	public function loadPermitions()
	{
		global $db;
		/*
		$providers = $shop->getProviders();
		
		if((self::getId() > 0) && (self::getItemLoaded('Users') == false))
		{
			$sql  = 'SELECT ptg.provider_id FROM '.DB_PERFIX.'product_provider_to_groups AS ptg ';
			$sql .= 'LEFT JOIN '.DB_PERFIX.'product_providers AS pr ON pr.id=ptg.provider_id ';
			$sql .= 'WHERE ptg.group_id='.self::getId().' AND pr.id=ptg.provider_id ORDER BY pr.title ASC;';
			
			$data = $db->fetch($sql, CACHE_TTL);
			if(is_array($data))
			{
				foreach($data as $row)
				{ 
					if($shop->getProviders($row['provider_id']))
					{ $this->Providers[$row['provider_id']] = $shop->getProvider($row['provider_id']); }
				}
			}
			self::setItemLoaded('Users', true);
		}
		*/
	}
	
	public function update()
	{
		if((self::getId() > 0) && (self::getDataChanged()))
		{
			$sql  = 'UPDATE '.DB_PERFIX.'user_groups SET ';
			$sql .= '`title`="'.self::formatText(self::getTitle()).'", ';
			$sql .= '`level`='.self::getLevel().' ';
			$sql .= ' WHERE id='.self::getId().' LIMIT 1;';
			mysql_query($sql);
		}
	}
}
?>